package com.liujun.spring4.demo.aop.application.property.editor;

import java.beans.PropertyEditorSupport;


/**
 * 自定义的属性编辑器
 * @author liujun
 * @version 0.0.1
 */
public class CustomCarEditor extends PropertyEditorSupport {

    @Override
    public void setAsText(String text) throws IllegalArgumentException {

        if(null == text && "".equals(text))
        {
            throw new IllegalArgumentException("curr input text format error");
        }

        String[] input = text.split(",");
        Car car = new Car();
        car.setBrand(input[0]);
        car.setMaxSpeed(Integer.parseInt(input[1]));
        car.setPrice(Double.parseDouble(input[2]));

        setValue(car);

    }
}
